package com.letoo.dragon.api.controller.internal.sms;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.letoo.dragon.common.domain.Result;
import com.letoo.dragon.common.domain.ResultCode;
import com.letoo.dragon.core.service.AliyunSmsService;
import com.letoo.dragon.request.SendSmsRequest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * APP基本配置信息控制器
 * 
 * @author dengjie
 *
 */
@Api(value = "阿里云sms短信服务控制器")
@RestController
@RequestMapping("/int/sms")
public class AliyunSmsController {

    private static final Logger LOG = LoggerFactory.getLogger(AliyunSmsController.class);

    @Autowired
    private AliyunSmsService aliyunSmsService;

    /**
     * 发送短信内部接口
     * 
     * 
     * @return 是否成功。如果发生异常，则返回系统错误
     */
    @ApiOperation(value = "EXT0009 发送短信内部接口", notes = "")
    @RequestMapping(value = "/send", method = RequestMethod.POST, produces = "application/vnd.dragon.app-v1.0+json")
    public Result sendSms(@RequestBody SendSmsRequest sendSmsRequest) {
        aliyunSmsService.sendSms(sendSmsRequest.getPhoneNumberArr(), sendSmsRequest.getParamStrings(),
                sendSmsRequest.getTemplateCode());
        Result res = new Result(ResultCode.COMMON_SUCCESS, true);
        return res;
    }

}
